/**
 * 
 */
package com.milk_shop.dao.imp;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Component;

import com.milk_shop.model.Package;

@Component
public class PackageDaoImp extends BaseDao<Package> {
	
	@Override
	public List<Package> getAll(){
		Session session = sessionFactory.getCurrentSession();
		Query query = session.createQuery("from package");
		return getList(query);
	}
	
	@Override
	public Package getModelById(int id) {
		Session session = sessionFactory.getCurrentSession();
		Query query = session.createQuery("from package where id =:id").setParameter("id", id);
		return getModel(query);
	}

	@Resource
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}
	
	@Override
	protected Class<Package> getType() {
		return Package.class;
	}
}
